package co.edu.javeriana.konigsberg.xavier.gui.bean;


import java.math.BigInteger;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import co.edu.javeriana.konigsberg.xavier.dto.AreaGestionDTO;
import co.edu.javeriana.konigsberg.xavier.dto.UsuarioDTO;
import co.edu.javeriana.konigsberg.xavier.servicio.AreaGestionServicioLocal;

@ManagedBean(name="areaGestionBean")
@SessionScoped
public class AreaGestionBean extends ManagerBean{
	private static final long serialVersionUID = 1L;

	@EJB
	private AreaGestionServicioLocal areaGestionServicio;
	
	private Map<String,BigInteger> areasGestion;
	
	public Map<String, BigInteger> getAreasGestion() {
		if(areasGestion == null){
			areasGestion = new HashMap<String, BigInteger>();
			List<AreaGestionDTO> areaGestionDTOs = areaGestionServicio.obtenerLista();
			for (AreaGestionDTO areaGestionDTO : areaGestionDTOs) {
				areasGestion.put(areaGestionDTO.getNombreAreaGestion(), areaGestionDTO.getIdAreaGestion());
			}
		}
//		UsuarioDTO usuarioDTO = obtenerUsuario();
//		if(usuarioDTO.getAreaGestionDTO() != null){
//			Map<String,BigInteger> areasGestionUsuario = new HashMap<String, BigInteger>();
//			areasGestionUsuario.put(usuarioDTO.getAreaGestionDTO().getNombreAreaGestion(), usuarioDTO.getAreaGestionDTO().getIdAreaGestion());
//			return areasGestionUsuario;
//		}
		return areasGestion;
	}
	public void setAreasGestion(Map<String, BigInteger> areasGestion) {
		this.areasGestion = areasGestion;
	}	
	
	private BigInteger idAreaGestion;
	
	public AreaGestionDTO obtenerSeleccionado(){
		AreaGestionDTO areaGestionDTO = areaGestionServicio.obtenerAreaGestionPorId(getIdAreaGestion());
		return areaGestionDTO;
	}
	public BigInteger getIdAreaGestion() {
		return idAreaGestion;
	}
	public void setIdAreaGestion(BigInteger idAreaGestion) {
		this.idAreaGestion = idAreaGestion;
	}
}
